<!--
  @文件名： index
  @来源：YongPing.Wang|2023/11/19 17:23
  @描述：
-->
<template>
  <svg :class="svgClass" v-bind="$attrs" :style="{ color: color }">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts">
  import { computed } from 'vue'
  const props = defineProps({
    name: {
      type: String,
      required: true,
    },
    color: {
      type: String,
      default: '',
    },
  })
  const iconName = computed(() => `#icon-${props.name}`)
  const svgClass = computed(() => {
    if (props.name) return `LG-icon icon-${props.name}`
    return 'svg-icon'
  })
</script>

<style scoped lang="scss">
  .LG-icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: middle;
  }
</style>
